/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mall;

import java.util.List;
import javax.faces.bean.*;
import mall.db.dao.FloorDAO;
import mall.db.entities.Floor;

/**
 *
 * @author Iaroslav_Mazai
 */
@ManagedBean(name = "floors")
@SessionScoped
public class FloorsBean {

	private FloorDAO fd = new FloorDAO();
	private Floor selectedFloor;

	public FloorsBean() {
	}

	public Floor getSelectedFloor() {
		return selectedFloor;
	}

	public void setSelectedFloor(Floor selectedFloor) {
		this.selectedFloor = selectedFloor;
	}

	public List<Floor> getFloorsList() {
		return fd.findAll();
	}

	public void deleteFloor() {
		fd.remove(selectedFloor);
	}

	public void updateFloor() {
		fd.update(selectedFloor);
	}

	public void createFloor() {
		Floor newFloor = new Floor();
		fd.save(newFloor);
	}
}
